home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / PInterfaces / ATA.p < prev    next >
Text File  |  1996-05-01  |  52KB  |  988 lines

  1. {
  2.      File:        ATA.p
  3.  
  4.      Contains:    ATA (PC/AT Attachment) Interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT ATA;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __ATA__}
  28. {$SETC __ATA__ := 1}
  29.  
  30. {$I+}
  31. {$SETC ATAIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40.  
  41. {$PUSH}
  42. {$ALIGN MAC68K}
  43. {$LibExport+}
  44.  
  45. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  46. {  This is the structure used for the AT Interface core routines below  }
  47.  
  48. CONST
  49.     kATATrap                    = $AAF1;                        {  Manager trap number <This should be defined in Traps.h> }
  50.     kATAPBVers1                    = $01;                            {  parameter block version number 1 }
  51.     kATAPBVers2                    = $02;                            {  parameter block version number for structures }
  52.     kATAPBVers3                    = $03;                            {  parameter block version for ATA times }
  53.     kATADefaultBlockSize        = 512;                            {  default block size }
  54.  
  55. {  Used to determine the presence of traps }
  56.     kFSMTrap                    = $AC;
  57.     mDQEChanged                    = 1;                            {  DQE has changed  }
  58.  
  59. {  Task file definition *** Error Register *** }
  60.     bATABadBlock                = 7;                            {  bit number of bad block error bit }
  61.     bATAUncorrectable            = 6;                            {  bit number of uncorrectable error bit }
  62.     bATAMediaChanged            = 5;                            {  bit number of media changed indicator }
  63.     bATAIDNotFound                = 4;                            {  bit number of ID not found error bit }
  64.     bATAMediaChangeReq            = 3;                            {  bit number of media changed request }
  65.     bATACommandAborted            = 2;                            {  bit number of command abort bit }
  66.     bATATrack0NotFound            = 1;                            {  bit number of track not found }
  67.     bATAAddressNotFound            = 0;                            {  bit number of address mark not found }
  68.     mATABadBlock                = $80;                            {  Bad Block Detected }
  69.     mATAUncorrectable            = $40;                            {  Uncorrectable Data Error }
  70.     mATAMediaChanged            = $20;                            {  Media Changed Indicator (for removable) }
  71.     mATAIDNotFound                = $10;                            {  ID Not Found }
  72.     mATAMediaChangeReq            = $08;                            {  Media Change Requested (NOT IMPLEMENTED) }
  73.     mATACommandAborted            = $04;                            {  Aborted Command }
  74.     mATATrack0NotFound            = $02;                            {  Track 0 Not Found }
  75.     mATAAddressNotFound            = $01;                            {  Address Mark Not Found }
  76.  
  77. {  Task file definition *** ataTFSDH Register *** }
  78.     mATAHeadNumber                = $0F;                            {  Head Number (bits 0-3)  }
  79.     mATASectorSize                = $A0;                            {  bit 7=1; bit 5 = 01 (512 sector size) <DP4> }
  80.     mATADriveSelect                = $10;                            {  Drive (0 = master, 1 = slave)  }
  81.     mATALBASelect                = $40;                            {  LBA mode bit (0 = chs, 1 = LBA) }
  82.  
  83. {  Task file definition *** Status Register *** }
  84.     bATABusy                    = 7;                            {  bit number of BSY bit }
  85.     bATADriveReady                = 6;                            {  bit number of drive ready bit }
  86.     bATAWriteFault                = 5;                            {  bit number of write fault bit }
  87.     bATASeekComplete            = 4;                            {  bit number of seek complete bit }
  88.     bATADataRequest                = 3;                            {  bit number of data request bit }
  89.     bATADataCorrected            = 2;                            {  bit number of data corrected bit }
  90.     bATAIndex                    = 1;                            {  bit number of index mark }
  91.     bATAError                    = 0;                            {  bit number of error bit }
  92.     mATABusy                    = $80;                            {  Unit is busy }
  93.     mATADriveReady                = $40;                            {  Unit is ready }
  94.     mATAWriteFault                = $20;                            {  Unit has a write fault condition }
  95.     mATASeekComplete            = $10;                            {  Unit seek complete }
  96.     mATADataRequest                = $08;                            {  Unit data request }
  97.     mATADataCorrected            = $04;                            {  Data corrected }
  98.     mATAIndex                    = $02;                            {  Index mark - NOT USED }
  99.     mATAError                    = $01;                            {  Error condition - see error register }
  100.  
  101. {  ATA Command Opcode definition }
  102.     kATAcmdWORetry                = $01;                            {  Without I/O retry option }
  103.     kATAcmdNOP                    = $0000;                        {  NOP operation - media detect }
  104.     kATAcmdRecal                = $0010;                        {  Recalibrate command  }
  105.     kATAcmdRead                    = $0020;                        {  Read command  }
  106.     kATAcmdReadLong                = $0022;                        {  Read Long command }
  107.     kATAcmdWrite                = $0030;                        {  Write command  }
  108.     kATAcmdWriteLong            = $0032;                        {  Write Long }
  109.     kATAcmdReadVerify            = $0040;                        {  Read Verify command  }
  110.     kATAcmdFormatTrack            = $0050;                        {  Format Track command  }
  111.     kATAcmdSeek                    = $0070;                        {  Seek command  }
  112.     kATAcmdDiagnostic            = $0090;                        {  Drive Diagnostic command  }
  113.     kATAcmdInitDrive            = $0091;                        {  Init drive parameters command  }
  114.     kATAcmdReadMultiple            = $00C4;                        {  Read multiple }
  115.     kATAcmdWriteMultiple        = $00C5;                        {  Write multiple }
  116.     kATAcmdSetRWMultiple        = $00C6;                        {  Set Multiple for Read/Write Multiple }
  117.     kATAcmdReadDMA                = $00C8;                        {  Read DMA (with retries) }
  118.     kATAcmdWriteDMA                = $00CA;                        {  Write DMA (with retries) }
  119.     kATAcmdMCAcknowledge        = $00DB;                        {  Acknowledge media change - removable }
  120.     kATAcmdStandbyImmed            = $00E0;                        {  Standby Immediate }
  121.     kATAcmdIdleImmed            = $00E1;                        {  Idle Immediate }
  122.     kATAcmdStandby                = $00E2;                        {  Standby }
  123.     kATAcmdIdle                    = $00E3;                        {  Idle }
  124.     kATAcmdReadBuffer            = $00E4;                        {  Read sector buffer command  }
  125.     kATAcmdCheckPowerMode        = $00E5;                        {  Check power mode command    <04/04/94> }
  126.     kATAcmdSleep                = $00E6;                        {  Sleep }
  127.     kATAcmdWriteBuffer            = $00E8;                        {  Write sector buffer command  }
  128.     kATAcmdDriveIdentify        = $00EC;                        {  Identify Drive command  }
  129.     kATAcmdSetFeatures            = $00EF;                        {  Set Features }
  130.  
  131. {  Set feature command opcodes }
  132.     kATAEnableWriteCache        = $02;                            {         Enable write cache }
  133.     kATASetTransferMode            = $03;                            {         Set transfer mode }
  134.     kATASetPIOMode                = $08;                            {         PIO Flow Control Tx Mode bit }
  135.     kATAEnableECC                = $88;                            {         ECC enable }
  136.     kATAEnableRetry                = $99;                            {         Retry enable }
  137.     kATAEnableReadAhead            = $AA;                            {         Read look-ahead enable }
  138.  
  139. {  Device Register Images  (8 bytes)  }
  140.  
  141. TYPE
  142.     ataTaskFilePtr = ^ataTaskFile;
  143.     ataTaskFile = RECORD
  144.         ataTFFeatures:            SInt8;                                    {  <-> Error(R) or ataTFFeatures(W) register image  }
  145.         ataTFCount:                SInt8;                                    {  <-> Sector count/remaining  }
  146.         ataTFSector:            SInt8;                                    {  <-> Sector start/finish  }
  147.         ataTFReserved:            SInt8;                                    {  reserved                     }
  148.         ataTFCylinder:            UInt16;                                    {  <-> ataTFCylinder (Big endian)  }
  149.         ataTFSDH:                SInt8;                                    {  <-> ataTFSDH register image }
  150.         ataTFCommand:            SInt8;                                    {  <-> Status(R) or Command(W) register image  }
  151.     END;
  152.  
  153. {  ATA Manager Function Code Definition }
  154.  
  155. CONST
  156.     kATAMgrNOP                    = $00;                            {  No Operation }
  157.     kATAMgrExecIO                = $01;                            {  Execute ATA I/O }
  158.     kATAMgrBusInquiry            = $03;                            {  Bus Inquiry }
  159.     kATAMgrQRelease                = $04;                            {  I/O Queue Release }
  160.     kATAMgrAbort                = $10;                            {  Abort command }
  161.     kATAMgrBusReset                = $11;                            {  Reset ATA bus }
  162.     kATAMgrRegAccess            = $12;                            {  Register Access }
  163.     kATAMgrDriveIdentify        = $13;                            {  Drive Identify            <DP03/10/94> }
  164.     kATAMgrDriverLoad            = $82;                            {  Load driver from either Media, ROM, etc. }
  165.     kATAMgrDriveRegister        = $85;                            {  Register a driver        <4/18/94> }
  166.     kATAMgrFindDriverRefnum        = $86;                            {  lookup a driver refnum    <4/18/94> }
  167.     kATAMgrRemoveDriverRefnum    = $87;                            {  De-register a driver    <4/18/94> }
  168.     kATAMgrModifyEventMask        = $88;                            {  Modify driver event mask }
  169.     kATAMgrDriveEject            = $89;                            {  Eject the drive        <8/1/94> }
  170.     kATAMgrGetDrvConfiguration    = $8A;                            {  Get device configuration    <8/6/94> }
  171.     kATAMgrSetDrvConfiguration    = $8B;                            {  Set device configuration <8/6/94> }
  172.     kATAMgrGetLocationIcon        = $8C;                            {  Get card location icon    <SM4> }
  173.     kATAMgrManagerInquiry        = $90;                            {  Manager Inquiry }
  174.     kATAMgrManagerInit            = $91;                            {  Manager initialization }
  175.     kATAMgrManagerShutdown        = $92;                            {  Manager ShutDown }
  176.  
  177. {  'ATAFlags' field of the PB header definition }
  178.     bATAFlagUseConfigSpeed        = 15;                            {  bit number of use default speed flag }
  179.     bATAFlagByteSwap            = 14;                            {  bit number of byte swap flag }
  180.     bATAFlagIORead                = 13;                            {  bit number of I/O read flag }
  181.     bATAFlagIOWrite                = 12;                            {  bit number of I/O write flag }
  182.     bATAFlagImmediate            = 11;                            {  bit number of immediate flag }
  183.     bATAFlagQLock                = 10;                            {  bit number of que lock on error }
  184.     bATAFlagScatterGather1        = 9;                            {  bit number of scatter gather }
  185.     bATAFlagScatterGather0        = 8;                            {  bit numbers of scatter gather }
  186.     bATAFlagUseDMA                = 7;                            {  bit number of use DMA flag }
  187.     bATAFlagProtocol1            = 5;                            {  bit number of scatter gather }
  188.     bATAFlagProtocol0            = 4;                            {  bit numbers of protocol specifier }
  189.     bATAFlagTFRead                = 3;                            {  bit number of register update }
  190.     bATAFlagLEDEnable            = 0;                            {  bit number of LED enable }
  191.     mATAFlagUseConfigSpeed        = $8000;
  192.     mATAFlagByteSwap            = $4000;                        {  Swap data bytes (read - after; write - before) }
  193.     mATAFlagIORead                = $2000;                        {  Read (in) operation }
  194.     mATAFlagIOWrite                = $1000;                        {  Write (out) operation }
  195.     mATAFlagImmediate            = $0800;                        {  Head of Que; Immediate operation }
  196.     mATAFlagQLock                = $0400;                        {  Manager queue lock on error (freeze the queue) }
  197.     mATAFlagScatterGather1        = $0200;
  198.     mATAFlagScatterGather0        = $0100;                        {  Scatter gather enable }
  199.     mATAFlagScatterGathers        = $0300;                        {  host scatter gather type = currently type 1 supported }
  200.     mATAFlagUseDMA                = $80;
  201.     mATAFlagProtocol1            = $20;                            {  ATAPI protocol indicator <06/15/94> }
  202.     mATAFlagProtocol0            = $10;                            {  PCMCIA protocol indicator <06/15/94> }
  203.     mATAFlagProtocols            = $30;                            {  mask for protocol type field    <06/15/94> }
  204.     mATAFlagTFRead                = $08;                            {  update reg block request upon detection of an error }
  205.     mATAFlagLEDEnable            = $01;                            {  socket LED enable }
  206.  
  207. {  Parameter block header definition - common for all PBs (48 bytes) }
  208.  
  209. TYPE
  210.     ataPBHeaderPtr = ^ataPBHeader;
  211.     ataPBHeader = RECORD
  212.                                                                         {  Start of cloned common header ataPBHdr  }
  213.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  214.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  215.         ataPBVers:                SInt8;                                    {  -->: parameter block version number }
  216.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  217.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  218.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  219.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  220.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  221.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  222.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  223.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  224.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  225.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  226.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  227.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  228.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  229.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  230.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  231.                                                                         {  End of cloned common header ataPBHdr }
  232.     END;
  233.  
  234. {  data request entry structure (16 bytes) }
  235.     IOBlockPtr = ^IOBlock;
  236.     IOBlock = RECORD
  237.         ataPBBuffer:            Ptr;                                    {  -->: Data buffer pointer }
  238.         ataPBByteCount:            UInt32;                                    {  -->: Data transfer length in bytes }
  239.     END;
  240.  
  241. {
  242.  For ATAPI devices the ExtendedPB field is a pointer to the Command Packet
  243.  record which exists of an array of words structured as follows...    <06/15/94>
  244. }
  245.     ATAPICmdPacketPtr = ^ATAPICmdPacket;
  246.     ATAPICmdPacket = RECORD
  247.         atapiPacketSize:        SInt16;                                    {  Size of command packet in bytes    <06/15/94> }
  248.         atapiCommandByte:        ARRAY [0..7] OF SInt16;                    {  The command packet itself    <06/15/94> }
  249.     END;
  250.  
  251. {  Manager parameter block structure (96 bytes) }
  252.     ataIOPBPtr = ^ataIOPB;
  253.     ataIOPB = RECORD
  254.                                                                         {  Start of cloned common header ataPBHdr }
  255.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  256.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  257.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  258.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  259.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  260.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  261.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  262.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  263.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  264.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  265.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  266.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  267.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  268.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  269.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  270.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  271.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  272.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  273.                                                                         {  End of cloned common header ataPBHdr }
  274.         ataPBStatusRegister:    SInt8;                                    {  <--: Last ATA status image }
  275.         ataPBErrorRegister:        SInt8;                                    {  <--: Last ATA error image-valid if lsb of Status set }
  276.         ataPBReserved5:            SInt16;                                    {  Reserved }
  277.         ataPBLogicalBlockSize:    UInt32;                                    {  -->: Blind transfer size per interrupt (Logical block size) }
  278.         ataPBBuffer:            Ptr;                                    {  -->: Data buffer pointer }
  279.         ataPBByteCount:            UInt32;                                    {  -->: Data transfer length in bytes }
  280.         ataPBActualTxCount:        UInt32;                                    {  <--: Actual transfer count }
  281.         ataPBReserved6:            UInt32;                                    {  Reserved }
  282.         ataPBTaskFile:            ataTaskFile;                            {  <->:    Device register images }
  283.         ataPBPacketPtr:            ATAPICmdPacketPtr;                        {  -->: ATAPI packet command block pointer (valid with ATAPI bit set) }
  284.         ataPBReserved7:            ARRAY [0..5] OF SInt16;                    {  Reserved for future expansion }
  285.     END;
  286.  
  287. {
  288.  Parameter block structure for bus and Manager inquiry command
  289.  Manager parameter block structure
  290. }
  291.     ataBusInquiryPtr = ^ataBusInquiry;
  292.     ataBusInquiry = RECORD
  293.                                                                         {  Start of cloned common header ataPBHdr }
  294.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  295.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  296.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  297.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  298.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  299.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  300.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  301.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  302.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  303.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  304.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  305.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  306.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  307.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  308.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  309.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  310.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  311.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  312.                                                                         {  End of cloned common header ataPBHdr }
  313.         ataEngineCount:            UInt16;                                    {  <--: TBD; zero for now }
  314.         ataPBReserved5:            UInt16;                                    {  Reserved }
  315.         ataDataTypes:            UInt32;                                    {  <--: TBD; zero for now }
  316.         ataIOpbSize:            UInt16;                                    {  <--: Size of ATA IO PB }
  317.         ataMaxIOpbSize:            UInt16;                                    {  <--: TBD; zero for now }
  318.         ataFeatureFlags:        UInt32;                                    {  <--: TBD }
  319.         ataVersionNum:            SInt8;                                    {  <--: Version number for the HBA }
  320.         ataHBAInquiry:            SInt8;                                    {  <--: TBD; zero for now }
  321.         ataPBReserved6:            UInt16;                                    {  Reserved }
  322.         ataHBAPrivPtr:            UInt32;                                    {  <--: Ptr to HBA private data area }
  323.         ataHBAPrivSize:            UInt32;                                    {  <--: Size of HBA private data area }
  324.         ataAsyncFlags:            UInt32;                                    {  <--: Event capability for callback }
  325.         ataPBReserved7:            ARRAY [0..3] OF UInt32;                    {  Reserved }
  326.         ataReserved4:            UInt32;                                    {  Reserved }
  327.         ataReserved5:            ARRAY [0..15] OF SInt8;                    {  TBD }
  328.         ataHBAVendor:            ARRAY [0..15] OF SInt8;                    {  <--: Vendor ID of the HBA }
  329.         ataContrlFamily:        ARRAY [0..15] OF SInt8;                    {  <--: Family of ATA Controller }
  330.         ataContrlType:            ARRAY [0..15] OF SInt8;                    {  <--: Model number of controller }
  331.         ataXPTversion:            ARRAY [0..3] OF SInt8;                    {  <--: version number of XPT }
  332.         ataResrved6:            ARRAY [0..3] OF SInt8;                    {  Reserved }
  333.         ataHBAversion:            ARRAY [0..3] OF SInt8;                    {  <--: version number of HBA }
  334.         ataHBAslotType:            SInt8;                                    {  <--: type of slot }
  335.         ataHBAslotNum:            SInt8;                                    {  <--: slot number of the HBA }
  336.         ataReserved7:            UInt16;                                    {  Reserved }
  337.         ataReserved8:            UInt32;                                    {  Reserved }
  338.     END;
  339.  
  340. {  Manager parameter block structure }
  341.     ataMgrInquiryPtr = ^ataMgrInquiry;
  342.     ataMgrInquiry = RECORD
  343.                                                                         {  Start of cloned common header ataPBHdr }
  344.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  345.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  346.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  347.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  348.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  349.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  350.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  351.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  352.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  353.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  354.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  355.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  356.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  357.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  358.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  359.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  360.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  361.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  362.                                                                         {  End of cloned common header ataPBHdr }
  363.         ataMgrVersion:            NumVersion;                                {  Manager Version information }
  364.         ataMgrPBVers:            SInt8;                                    {  <--: Manager PB version number supported }
  365.         Reserved1:                SInt8;                                    {  Reserved }
  366.         ataBusCnt:                UInt16;                                    {  <--: Number of ATA buses in the system }
  367.         ataDevCnt:                UInt16;                                    {  <--: Total number of ATA devices detected }
  368.         ataPioModes:            SInt8;                                    {  <--: Maximum Programmed I/O speed mode supported }
  369.         Reserved2:                SInt8;                                    {  Reserved }
  370.         ataIOClkResolution:        UInt16;                                    {  <--: IO Clock resolution in nsec (Not supported) }
  371.         ataSingleDMAModes:        SInt8;                                    {  <--: Single Word DMA modes supported     }
  372.         ataMultiDMAModes:        SInt8;                                    {  <--: Multiword DMA modes supported }
  373.         Reserved:                ARRAY [0..15] OF SInt16;                {  Reserved for future expansion }
  374.     END;
  375.  
  376. {
  377.  Parameter block structure for Abort command
  378.  Manager parameter block structure
  379. }
  380.     ataAbortPtr = ^ataAbort;
  381.     ataAbort = RECORD
  382.                                                                         {  Start of cloned common header ataPBHdr }
  383.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  384.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  385.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  386.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  387.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  388.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  389.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  390.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  391.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  392.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  393.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  394.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  395.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  396.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  397.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  398.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  399.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  400.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  401.                                                                         {  End of cloned common header ataPBHdr }
  402.         ataAbortPB:                ataIOPBPtr;                                {  -->: Parameter block to be aborted }
  403.         Reserved:                ARRAY [0..21] OF SInt16;                {  Reserved for future expansion }
  404.     END;
  405.  
  406. {  Manager parameter block structure }
  407.     ATAEventRecPtr = ^ATAEventRec;
  408.     ATAEventRec = RECORD
  409.         ataEventCode:            UInt16;                                    {  --> ATA event code }
  410.         ataPhysicalID:            UInt16;                                    {  --> Physical drive reference }
  411.         ataDrvrContext:            SInt32;                                    {  Context pointer saved by driver }
  412.     END;
  413.  
  414.     ATAClientProcPtr = ProcPtr;  { FUNCTION ATAClient(ataERPtr: ATAEventRecPtr): SInt16; }
  415.  
  416.     ATAClientUPP = UniversalProcPtr;
  417.  
  418. CONST
  419.     uppATAClientProcInfo = $000000E0;
  420.  
  421. FUNCTION NewATAClientProc(userRoutine: ATAClientProcPtr): ATAClientUPP;
  422.     {$IFC NOT GENERATINGCFM }
  423.     INLINE $2E9F;
  424.     {$ENDC}
  425.  
  426. FUNCTION CallATAClientProc(ataERPtr: ATAEventRecPtr; userRoutine: ATAClientUPP): SInt16;
  427.     {$IFC NOT GENERATINGCFM}
  428.     INLINE $205F, $4E90;
  429.     {$ENDC}
  430. {
  431.  Parameter block structure for Driver Register command
  432.  Manager parameter block structure
  433. }
  434.  
  435. TYPE
  436.     ataDrvrRegisterPtr = ^ataDrvrRegister;
  437.     ataDrvrRegister = RECORD
  438.                                                                         {  Start of cloned common header ataPBHdr }
  439.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  440.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  441.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  442.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  443.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  444.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  445.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  446.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  447.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  448.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  449.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  450.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  451.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  452.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  453.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  454.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  455.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  456.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  457.                                                                         {  End of cloned common header ataPBHdr }
  458.         ataDrvrRefNum:            SInt16;                                    {  <->: Driver reference number }
  459.         ataDrvrFlags:            UInt16;                                    {  -->: 1 = loader driver if ataPBDeviceID = -1 (PB2) }
  460.         ataDeviceNextID:        UInt16;                                    {  <--: used to specified the next drive ID }
  461.         ataDrvrLoadPriv:        SInt16;                                    {  Driver loader private storage }
  462.         ataEventHandler:        ATAClientUPP;                            {  <->: Pointer to ATA event callback routine (PB2) }
  463.         ataDrvrContext:            SInt32;                                    {  <->: Context data saved by driver (PB2) }
  464.         ataEventMask:            SInt32;                                    {  <->: Set to 1 for notification of event (PB2) }
  465.         Reserved:                ARRAY [0..13] OF SInt16;                {  Reserved for future expansion - from [21] (PB2) }
  466.     END;
  467.  
  468. {  Parameter block structure for Modify driver event mask command }
  469.     ataModifyEventMaskPtr = ^ataModifyEventMask;
  470.     ataModifyEventMask = RECORD
  471.                                                                         {  Start of cloned common header ataPBHdr }
  472.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  473.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  474.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  475.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  476.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  477.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  478.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  479.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  480.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  481.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  482.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  483.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  484.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  485.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  486.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  487.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  488.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  489.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  490.                                                                         {  End of cloned common header ataPBHdr }
  491.         ataModifiedEventMask:    SInt32;                                    {  -->: new event mask value }
  492.         Reserved:                ARRAY [0..21] OF SInt16;                {  Reserved for future expansion }
  493.     END;
  494.  
  495. {  'ataRegMask' field of the ataRegAccess definition }
  496.  
  497. CONST
  498.     bATAAltSDevCValid            = 14;                            {  bit number of alternate status/device cntrl valid bit }
  499.     bATAStatusCmdValid            = 7;                            {  bit number of status/command valid bit }
  500.     bATASDHValid                = 6;                            {  bit number of ataTFSDH valid bit }
  501.     bATACylinderHiValid            = 5;                            {  bit number of cylinder high valid bit }
  502.     bATACylinderLoValid            = 4;                            {  bit number of cylinder low valid bit }
  503.     bATASectorNumValid            = 3;                            {  bit number of sector number valid bit }
  504.     bATASectorCntValid            = 2;                            {  bit number of sector count valid bit }
  505.     bATAErrFeaturesValid        = 1;                            {  bit number of error/features valid bit }
  506.     bATADataValid                = 0;                            {  bit number of data valid bit }
  507.     mATAAltSDevCValid            = $4000;                        {  alternate status/device control valid }
  508.     mATAStatusCmdValid            = $80;                            {  status/command valid }
  509.     mATASDHValid                = $40;                            {  ataTFSDH valid }
  510.     mATACylinderHiValid            = $20;                            {  cylinder high valid }
  511.     mATACylinderLoValid            = $10;                            {  cylinder low valid }
  512.     mATASectorNumValid            = $08;                            {  sector number valid }
  513.     mATASectorCntValid            = $04;                            {  sector count valid }
  514.     mATAErrFeaturesValid        = $02;                            {  error/features valid }
  515.     mATADataValid                = $01;                            {  data valid }
  516.  
  517. {  Parameter block structure for device register access command }
  518.  
  519. TYPE
  520.     ataRegValueUnionPtr = ^ataRegValueUnion;
  521.     ataRegValueUnion = RECORD
  522.         CASE INTEGER OF
  523.         0: (
  524.             ataByteRegValue:    SInt8;                                    {  <->: Byte register value read or to be written }
  525.             );
  526.         1: (
  527.             ataWordRegValue:    UInt16;                                    {  <->: Word register value read or to be written }
  528.             );
  529.     END;
  530.  
  531. {  Manager parameter block structure }
  532.     ataRegAccessPtr = ^ataRegAccess;
  533.     ataRegAccess = RECORD
  534.                                                                         {  Start of cloned common header ataPBHdr }
  535.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  536.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  537.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  538.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  539.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  540.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  541.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  542.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  543.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  544.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  545.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  546.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  547.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  548.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  549.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  550.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  551.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  552.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  553.                                                                         {  End of cloned common header ataPBHdr }
  554.         ataRegSelect:            UInt16;                                    {  -->: Device Register Selector }
  555.                                                                         {             DataReg            0     }
  556.                                                                         {             ErrorReg(R) or FeaturesReg(W)    1 }
  557.                                                                         {             SecCntReg        2 }
  558.                                                                         {             SecNumReg        3 }
  559.                                                                         {             CylLoReg        4 }
  560.                                                                         {             CylHiReg        5 }
  561.                                                                         {             SDHReg            6 }
  562.                                                                         {             StatusReg(R) or CmdReg(W)        7 }
  563.                                                                         {             AltStatus(R) or DevCntr(W)    0E }
  564.         ataRegValue:            ataRegValueUnion;
  565.                                                                         {  Following fields are valid only if ataRegSelect = 0xFFFF }
  566.         ataRegMask:                UInt16;                                    {  -->: mask for register(s) to update }
  567.                                                                         {         bit 0 : data register valid }
  568.                                                                         {         bit 1 : error/feaures register valid }
  569.                                                                         {         bit 2 : sector count register valid }
  570.                                                                         {         bit 3 : sector number register valid }
  571.                                                                         {         bit 4 : cylinder low register valid }
  572.                                                                         {         bit 5 : cylinder high register valid }
  573.                                                                         {         bit 6 : ataTFSDH register valid }
  574.                                                                         {         bit 7 : status/command register valid }
  575.                                                                         {         bits 8 - 13 : reserved (set to 0) }
  576.                                                                         {         bit 14: alternate status / device control reg valid }
  577.                                                                         {          bit 15: reserved (set to 0) }
  578.         ataRegisterImage:        ataTaskFile;                            {  <->: register images }
  579.         ataAltSDevCReg:            SInt8;                                    {  <->: Alternate status(R) or Device Control(W) register image }
  580.         Reserved3:                SInt8;                                    {  Reserved }
  581.         Reserved:                ARRAY [0..15] OF SInt16;                {  Reserved for future expansion }
  582.     END;
  583.  
  584. {  Manager parameter block structure    <DP03/10/94> }
  585.     ataIdentifyPtr = ^ataIdentify;
  586.     ataIdentify = RECORD
  587.                                                                         {  Start of cloned common header ataPBHdr }
  588.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  589.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  590.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  591.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  592.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  593.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  594.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  595.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  596.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  597.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  598.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  599.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  600.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  601.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  602.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  603.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  604.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  605.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  606.                                                                         {  End of cloned common header ataPBHdr }
  607.         Reserved1:                ARRAY [0..3] OF UInt16;                    {  Reserved.  These are used internally by the Manager }
  608.         ataPBBuffer:            Ptr;                                    {  Buffer for the identify data (512 bytes) }
  609.         Reserved2:                ARRAY [0..11] OF UInt16;                {  Used internally by the ATA Manager }
  610.         Reserved3:                ARRAY [0..5] OF SInt16;                    {  Reserved for future expansion }
  611.     END;
  612.  
  613. {  'ataConfigSetting' field of the Get/Set Device Configuration definition <8/6/94> }
  614.  
  615. CONST
  616.     ATAPIpacketDRQ_bit            = 6;                            {  bit number of ATAPI command packet DRQ option }
  617.     ATAPIpacketDRQ                = $40;                            {  ATAPI command packet DRQ option }
  618.  
  619. {  atapcValid field definition }
  620.     bATApcAccessMode            = 0;
  621.     bATApcVcc                    = 1;
  622.     bATApcVpp1                    = 2;
  623.     bATApcVpp2                    = 3;
  624.     bATApcStatus                = 4;
  625.     bATApcPin                    = 5;
  626.     bATApcCopy                    = 6;
  627.     bATApcConfigIndex            = 7;
  628.     bATApcLockUnlock            = 15;
  629.     mATApcAccessMode            = $01;
  630.     mATApcVcc                    = $02;
  631.     mATApcVpp1                    = $04;
  632.     mATApcVpp2                    = $08;
  633.     mATApcStatus                = $10;
  634.     mATApcPin                    = $20;
  635.     mATApcCopy                    = $40;
  636.     mATApcConfigIndex            = $80;
  637.     mATApcLockUnlock            = $8000;
  638.  
  639. {  Device physical type & socket type indicator definition }
  640.     kATADeviceUnknown            = $00;                            {  no device or type undetermined }
  641.     kATADeviceATA                = $01;                            {  traditional ATA protocol device <7/29/94> }
  642.     kATADeviceATAPI                = $02;                            {  ATAPI protocol device    <7/29/94> }
  643.     kATADevicePCMCIA            = $03;                            {  PCMCIA ATA device        <7/29/94> }
  644.     kATASocketInternal            = $01;                            {  Internal ATA socket }
  645.     kATASocketMB                = $02;                            {  Media Bay socket }
  646.     kATASocketPCMCIA            = $03;                            {  PCMCIA socket }
  647.     kATAConfigReserved            = 7;                            {  number of reserved words at the end }
  648.  
  649. {
  650.  Get/Set Device Configuration parameter block structure <8/6/94>
  651.  Manager parameter block structure
  652. }
  653.  
  654. TYPE
  655.     ataDevConfigurationPtr = ^ataDevConfiguration;
  656.     ataDevConfiguration = RECORD
  657.                                                                         {  Start of cloned common header ataPBHdr }
  658.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  659.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  660.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  661.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  662.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  663.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  664.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  665.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  666.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  667.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  668.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  669.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  670.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  671.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  672.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  673.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  674.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  675.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  676.                                                                         {  End of cloned common header ataPBHdr }
  677.         ataConfigSetting:        SInt32;                                    {  <->: Configuration setting }
  678.                                                                         {       Bits 3 - 0: Reserved }
  679.                                                                         {       Bit 4: Reserved (allowLBAAccess) }
  680.                                                                         {       Bit 5: Reserved (allowRWMultiple) }
  681.                                                                         {       Bit 6: ATAPIpacketDRQ }
  682.                                                                         {         1 = Check for Interrupt DRQ on ATAPI command packet DRQ }
  683.                                                                         {         0 = Default: Check only for the assertion of command packet DRQ }
  684.                                                                         {       Bits 31 - 7: Reserved }
  685.         ataPIOSpeedMode:        SInt8;                                    {  <->: Device access speed in PIO Mode }
  686.         Reserved3:                SInt8;                                    {  Reserved to force word alignment }
  687.         atapcValid:                UInt16;                                    {  <->: Set when pcXXX fields are valid (atapcAccessMode - atapcConfigIndex) }
  688.                                                                         {         bit 0 - atapcAccessMode field valid, when set }
  689.                                                                         {         bit 1 - atapcVcc field valid, when set }
  690.                                                                         {         bit 2 - atapcVpp1 field valid, when set }
  691.                                                                         {         bit 3 - atapcVpp2 field valid, when set }
  692.                                                                         {         bit 4 - atapcStatus field valid, when set }
  693.                                                                         {         bit 5 - atapcPin field valid, when set }
  694.                                                                         {         bit 6 - atapcCopy field valid, when set }
  695.                                                                         {         bit 7 - atapcConfigIndex field valid, when set }
  696.                                                                         {         bits 14-8 - Reserved }
  697.                                                                         {         bit 15 - device lock/unlock request (write only) }
  698.         ataRWMultipleCount:        UInt16;                                    {  Reserved for future (not supported yet) }
  699.         ataSectorsPerCylinder:    UInt16;                                    {  Reserved for future (not supported yet) }
  700.         ataHeads:                UInt16;                                    {  Reserved for future (not supported yet) }
  701.         ataSectorsPerTrack:        UInt16;                                    {  Reserved for future (not supported yet) }
  702.         ataSocketNumber:        UInt16;                                    {  <--: Socket number used by the CardServices }
  703.                                                                         {         0xFF = socket number invalid (Not a CardServices device) }
  704.                                                                         {         other = socket number of the device }
  705.         ataSocketType:            SInt8;                                    {  <--: Specifies the socket type (get config only) }
  706.                                                                         {         00 = Unknown socket }
  707.                                                                         {          01 = Internal ATA bus }
  708.                                                                         {         02 = Media Bay }
  709.                                                                         {         03 = PCMCIA }
  710.         ataDeviceType:            SInt8;                                    {  <--: Specifies the device type (get config only) }
  711.                                                                         {         00 = Unknown device }
  712.                                                                         {         01 = standard ATA device (HD) }
  713.                                                                         {         02 = ATAPI device }
  714.                                                                         {         03 = PCMCIA ATA device }
  715.         atapcAccessMode:        SInt8;                                    {  <->: Access mode: Memory vs. I/O (PCMCIA only) }
  716.         atapcVcc:                SInt8;                                    {  <->: Voltage in tenths of a volt (PCMCIA only) }
  717.         atapcVpp1:                SInt8;                                    {  <->: Voltage in tenths of a volt (PCMCIA only) }
  718.         atapcVpp2:                SInt8;                                    {  <->: Voltage in tenths of a volt (PCMCIA only) }
  719.         atapcStatus:            SInt8;                                    {  <->: Card Status register setting (PCMCIA only) }
  720.         atapcPin:                SInt8;                                    {  <->: Card Pin register setting (PCMCIA only) }
  721.         atapcCopy:                SInt8;                                    {  <->: Card Socket/Copy register setting (PCMCIA only) }
  722.         atapcConfigIndex:        SInt8;                                    {  <->: Card Option register setting (PCMCIA only) }
  723.         ataSingleDMASpeed:        SInt8;                                    {  <->: Single Word DMA Timing Class }
  724.         ataMultiDMASpeed:        SInt8;                                    {  <->: Multiple Word DMA Timing Class }
  725.         ataPIOCycleTime:        UInt16;                                    {  <->:Cycle time for PIO mode }
  726.         ataMultiCycleTime:        UInt16;                                    {  <->:Cycle time for Multiword DMA mode }
  727.         Reserved1:                ARRAY [0..6] OF UInt16;                    {  Reserved for future }
  728.     END;
  729.  
  730. {  Get Card Location Icon/Text    <SM4> }
  731.  
  732. CONST
  733.     kATALargeIconHFS            = $0001;                        {  Large B&W icon with mask (HFS) }
  734.     kATALargeIconProDOS            = $0081;                        {  Large B&W icon with mask (ProDOS) }
  735.  
  736. {  Manager parameter block structure }
  737.  
  738. TYPE
  739.     ataLocationDataPtr = ^ataLocationData;
  740.     ataLocationData = RECORD
  741.                                                                         {  Start of cloned common header ataPBHdr }
  742.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  743.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  744.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  745.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  746.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  747.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  748.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  749.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  750.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  751.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  752.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  753.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  754.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  755.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  756.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  757.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  758.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  759.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  760.                                                                         {  End of cloned common header ataPBHdr }
  761.         ataIconType:            SInt16;                                    {  -->: icon type specifier }
  762.                                                                         {          1 = Large B&W icon with mask (256 bytes) }
  763.                                                                         {         0x81 = Same as 1, but ProDOS icon }
  764.         ataIconReserved:        SInt16;                                    {  Reserved to be longword aligned }
  765.         ataLocationIconPtr:        Ptr;                                    {  -->: Icon Data buffer pointer }
  766.         ataLocationStringPtr:    Ptr;                                    {  -->: Icon String buffer pointer }
  767.         Reserved1:                ARRAY [0..17] OF UInt16;                {  Reserved for future }
  768.     END;
  769.  
  770. {  ataOSType available }
  771.  
  772. CONST
  773.     kATAddTypeMacOS                = $0001;                        {  Blue Mac O/S ddType value }
  774.  
  775. {  The parameter block definition for all other ATA Manager functions. }
  776.  
  777. TYPE
  778.     ataGenericPtr = ^ataGeneric;
  779.     ataGeneric = RECORD
  780.                                                                         {  Start of cloned common header ataPBHdr }
  781.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  782.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  783.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  784.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  785.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  786.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  787.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  788.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  789.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  790.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  791.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  792.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  793.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  794.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  795.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  796.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  797.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  798.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  799.                                                                         {  End of cloned common header ataPBHdr }
  800.         Reserved:                ARRAY [0..23] OF UInt16;                {  Reserved for future }
  801.     END;
  802.  
  803.     ataPBPtr = ^ataPB;
  804.     ataPB = RECORD
  805.         CASE INTEGER OF
  806.         0: (
  807.             ataIOParamBlock:    ataIOPB;                                {  parameter block for I/O }
  808.             );
  809.         1: (
  810.             ataBIParamBlock:    ataBusInquiry;                            {  parameter block for bus inquiry }
  811.             );
  812.         2: (
  813.             ataMIParamBlock:    ataMgrInquiry;                            {  parameter block for Manager inquiry }
  814.             );
  815.         3: (
  816.             ataAbortParamBlock:    ataAbort;                                {  parameter block for abort }
  817.             );
  818.         4: (
  819.             ataDRParamBlock:    ataDrvrRegister;                        {  parameter block for driver register }
  820.             );
  821.         5: (
  822.             ataMEParamBlock:    ataModifyEventMask;                        {  parameter block for event mask modify }
  823.             );
  824.         6: (
  825.             ataRAParamBlock:    ataRegAccess;                            {  parameter block for register access }
  826.             );
  827.         7: (
  828.             ataDIParamBlock:    ataIdentify;                            {  parameter block for drive identify }
  829.             );
  830.         8: (
  831.             ataDCParamBlock:    ataDevConfiguration;                    {  parameter block for device configuration }
  832.             );
  833.         9: (
  834.             ataLDParamBlock:    ataLocationData;                        {  parameter block for location icon data }
  835.             );
  836.                                                                         { ataManagerInit    ataInitParamBlock;        // parameter block for Manager initialization }
  837.                                                                         { ataManagerShutDn    ataSDParamBlock;        // parameter block for Manager shutdown }
  838.                                                                         { ataDrvrLoad        ataDLParamBlock;        // parameter block for Driver loading }
  839.         10: (
  840.             ataGenericParamBlock: ataGeneric;                            {  parameter block for all other functions }
  841.             );
  842.     END;
  843.  
  844. {  The ATA Event codes... }
  845.  
  846. CONST
  847.     kATANullEvent                = $00;                            {  Just kidding -- nothing happened }
  848.     kATAOnlineEvent                = $01;                            {  An ATA device has come online }
  849.     kATAOfflineEvent            = $02;                            {  An ATA device has gone offline }
  850.     kATARemovedEvent            = $03;                            {  An ATA device has been removed from the bus }
  851.     kATAResetEvent                = $04;                            {  Someone gave a hard reset to the drive }
  852.     kATAOfflineRequest            = $05;                            {  Someone requesting to offline the drive }
  853.     kATAEjectRequest            = $06;                            {  Someone requesting to eject the drive }
  854.     kATAUpdateEvent                = $07;                            {  Potential configuration change reported by CardServices <SM4> }
  855.                                                                 {  The following describes bit definitions in the eventMask field of ataDrvrRegister }
  856.     bATANullEvent                = $01;                            {  null event bit }
  857.     bATAOnlineEvent                = $02;                            {  online event bit }
  858.     bATAOfflineEvent            = $04;                            {  offline event bit }
  859.     bATARemovedEvent            = $08;                            {  removed event bit }
  860.     bATAResetEvent                = $10;                            {  reset event bit }
  861.     bATAOfflineRequest            = $20;                            {  offline request event bit }
  862.     bATAEjectRequest            = $40;                            {  eject request event bit }
  863.     bATAUpdateEvent                = $80;                            {  configuration update event bit }
  864.  
  865.  
  866. TYPE
  867.     ATADispatchProcPtr = ProcPtr;  { FUNCTION ATADispatch(VAR pb: ataPB): OSErr; }
  868.  
  869.     ATADispatchUPP = UniversalProcPtr;
  870.  
  871. CONST
  872.     uppATADispatchProcInfo = $000000E0;
  873.  
  874. FUNCTION NewATADispatchProc(userRoutine: ATADispatchProcPtr): ATADispatchUPP;
  875.     {$IFC NOT GENERATINGCFM }
  876.     INLINE $2E9F;
  877.     {$ENDC}
  878.  
  879. FUNCTION CallATADispatchProc(VAR pb: ataPB; userRoutine: ATADispatchUPP): OSErr;
  880.     {$IFC NOT GENERATINGCFM}
  881.     INLINE $205F, $4E90;
  882.     {$ENDC}
  883. FUNCTION ataManager(VAR pb: ataPB): SInt16;
  884.     {$IFC NOT GENERATINGCFM}
  885.     INLINE $AAF1;
  886.     {$ENDC}
  887. {  Device Error codes: 0xDB42 - 0xDB5F     }
  888.  
  889. CONST
  890.     ATABaseErrCode                = -9406;                        {  Base error code - 0xDB42     }
  891.     ioPending                    = 1;                            {  Asynch I/O in progress status }
  892.     AT_NRdyErr                    = -9405;                        {  0xDB43: Drive not Ready  }
  893.     AT_IDNFErr                    = -9404;                        {  0xDB44: ID not found  }
  894.     AT_DMarkErr                    = -9403;                        {  0xDB45: Data mark not found  }
  895.     AT_BadBlkErr                = -9402;                        {  0xDB46: Bad Block  }
  896.     AT_CorDataErr                = -9401;                        {  0xDB47: Data was corrected  }
  897.     AT_UncDataErr                = -9400;                        {  0xDB48: Data was not corrected  }
  898.     AT_SeekErr                    = -9399;                        {  0xDB49: Seek error  }
  899.     AT_WrFltErr                    = -9398;                        {  0xDB4A: Write fault  }
  900.     AT_RecalErr                    = -9397;                        {  0xDB4B: Recalibrate failed  }
  901.     AT_AbortErr                    = -9396;                        {  0xDB4C: Command aborted by drive  }
  902.     AT_MCErr                    = -9394;                        {  0xDB4E: Media Changed error }
  903.     ATAPICheckErr                = -9393;                        {  0xDB4F: ATAPI Check condition <06/15/94> }
  904.                                                                 {  System error codes...Custom Driver Error Codes 0xDB60 - 0xDB6F }
  905.     DRVRCantAllocate            = -9376;                        {  0xDB60: Allocation error during initialization }
  906.     NoATAMgr                    = -9375;                        {  0xDB61: MgrInquiry failed => No ATA Manager }
  907.     ATAInitFail                    = -9374;                        {  0xDB62: Mgr Initialization failed }
  908.     ATABufFail                    = -9373;                        {  0xDB63: Device buffer test failure }
  909.     ATADevUnsupported            = -9372;                        {  0xDB64: Device type not supported }
  910.     ATAEjectDrvErr                = -9371;                        {  0xDB65: Could not eject the drive }
  911.                                                                 {  Manager Error Codes 0xDB70 - 0xDB8F }
  912.     ATAMgrNotInitialized        = -9360;                        {  0xDB70: Mgr has not been initialized }
  913.     ATAPBInvalid                = -9359;                        {  0xDB71: The bus base address couldn't be found }
  914.     ATAFuncNotSupported            = -9358;                        {  0xDB72: An unknown function code specified }
  915.     ATABusy                        = -9357;                        {  0xDB73: Selected device is busy }
  916.     ATATransTimeOut                = -9356;                        {  0xDB74: Transaction timeout detected }
  917.     ATAReqInProg                = -9355;                        {  0xDB75: Channel busy; channel is processing another cmd }
  918.     ATAUnknownState                = -9354;                        {  0xDB76: Device status register reflects an unknown state }
  919.     ATAQLocked                    = -9353;                        {  0xDB77: I/O Queue is locked due to previous I/O error. }
  920.     ATAReqAborted                = -9352;                        {  0xDB78: The I/O queue entry was aborted due to an abort req. }
  921.                                                                 {             or due to Manager shutdown. }
  922.     ATAUnableToAbort            = -9351;                        {  0xDB79: The I/O queue entry could not be aborted. }
  923.     ATAAbortedDueToRst            = -9350;                        {  0xDB7A: Request aborted due to a device reset command. }
  924.     ATAPIPhaseErr                = -9349;                        {  0xDB7B: Unexpected phase - ***IS THIS VALID ERROR??? <06/15/94> }
  925.     ATAPITxCntErr                = -9348;                        {  0xDB7C: Overrun/Underrun condition detected }
  926.     ATANoClientErr                = -9347;                        {  0xDB7D: No client present to handle the event }
  927.     ATAInternalErr                = -9346;                        {  0xDB7E: MagnumOpus returned an error }
  928.     ATABusErr                    = -9345;                        {  0xDB7F: Bus error detected on I/O     }
  929.     AT_NoAddrErr                = -9344;                        {  0xDB80: Invalid AT base adress  }
  930.     DriverLocked                = -9343;                        {  0xDB81: Current driver must be removed before adding another }
  931.     CantHandleEvent                = -9342;                        {  0xDB82: Particular event couldn't be handled (call others) }
  932.     ATAMgrMemoryErr                = -9341;                        {  0xDB83: Manager memory allocation error     }
  933.     ATASDFailErr                = -9340;                        {  0xDB84: Shutdown failure                 }
  934.     ATAXferParamErr                = -9339;                        {  0xDB85: I/O xfer parameters inconsistent  }
  935.     ATAXferModeErr                = -9338;                        {  0xDB86: I/O xfer mode not supported  }
  936.     ATAMgrConsistencyErr        = -9337;                        {  0XDB87: Manager detected internal inconsistency.  }
  937.     ATADmaXferErr                = -9336;                        {  0XDB88: fatal error in DMA side of transfer  }
  938.                                                                 {  Driver loader error Codes 0xDB90 - 0xDBA5 }
  939.     ATAInvalidDrvNum            = -9328;                        {  0xDB90: Invalid drive number from event }
  940.     ATAMemoryErr                = -9327;                        {  0xDB91: Memory allocation error }
  941.     ATANoDDMErr                    = -9326;                        {  0xDB92: No DDM found on media     }
  942.     ATANoDriverErr                = -9325;                        {  0xDB93: No driver found on the media     }
  943.  
  944. {  ------------------------    Version 1 definition -------------------------------     }
  945.     v1ATABaseErrCode            = $0700;                        {  This needs a home somewhere }
  946.     v1AT_NRdyErr                = $FFFFF901;                    {  0xF901: -0x1DBE  }
  947.     v1AT_IDNFErr                = $FFFFF904;                    {  0xF904: -0x1DC0  }
  948.     v1AT_DMarkErr                = $FFFFF905;                    {  0xF905: -0x1DC0  }
  949.     v1AT_BadBlkErr                = $FFFFF906;                    {  0xF906: -0x1DC0  }
  950.     v1AT_CorDataErr                = $FFFFF907;                    {  0xF907: -0x1DC0  }
  951.     v1AT_UncDataErr                = $FFFFF908;                    {  0xF908: -0x1DC0  }
  952.     v1AT_SeekErr                = $FFFFF909;                    {  0xF909: -0x1DC0  }
  953.     v1AT_WrFltErr                = $FFFFF90A;                    {  0xF90A: -0x1DC0  }
  954.     v1AT_RecalErr                = $FFFFF90B;                    {  0xF90B: -0x1DC0  }
  955.     v1AT_AbortErr                = $FFFFF90C;                    {  0xF90C: -0x1DC0  }
  956.     v1AT_NoAddrErr                = $FFFFF90D;                    {  0xF90D: -0x1D8D  }
  957.     v1AT_MCErr                    = $FFFFF90E;                    {  0xF90E: -0x1DC0 }
  958.                                                                 {  System error codes...Custom Driver Error Codes }
  959.     v1DRVRCantAllocate            = -1793;                        {  0xF8FF: -0x1D9F }
  960.     v1NoATAMgr                    = -1794;                        {  0xF8FE: -0x1D9D }
  961.     v1ATAInitFail                = -1795;                        {  0xF8FD: -0x1D9B }
  962.     v1ATABufFail                = -1796;                        {  0xF8FC: -0x1D99 }
  963.     v1ATADevUnsupported            = -1797;                        {  0xF8FB: -0x1c97 }
  964.                                                                 {  Manager Error Codes }
  965.     v1ATAMgrNotInitialized        = -1802;                        {  0xF8F6: -0x1D86 }
  966.     v1ATAPBInvalid                = -1803;                        {  0xF8F5: -0x1D84 }
  967.     v1ATAFuncNotSupported        = -1804;                        {  0xF8F4: -0x1D82 }
  968.     v1ATABusy                    = -1805;                        {  0xF8F3: -0x1D80 }
  969.     v1ATATransTimeOut            = -1806;                        {  0xF8F2: -0x1D7E }
  970.     v1ATAReqInProg                = -1807;                        {  0xF8F1: -0x1D7C }
  971.     v1ATAUnknownState            = -1808;                        {  0xF8F0: -0x1D7A }
  972.     v1ATAQLocked                = -1809;                        {  0xF8EF: -0x1D78 }
  973.     v1ATAReqAborted                = -1810;                        {  0xF8EE: -0x1D76 }
  974.     v1ATAUnableToAbort            = -1811;                        {  0xF8ED: -0x1D74 }
  975.     v1ATAAbortedDueToRst        = -1812;                        {  0xF8EC: -0x1D72 }
  976.  
  977. {$ENDC}
  978. {$ALIGN RESET}
  979. {$POP}
  980.  
  981. {$SETC UsingIncludes := ATAIncludes}
  982.  
  983. {$ENDC} {__ATA__}
  984.  
  985. {$IFC NOT UsingIncludes}
  986.  END.
  987. {$ENDC}
  988.